import 'package:wch/generated/json/base/json_convert_content.dart';
import 'package:wch/model/patient_device_list_entity.dart';

import '../../model/acquisition_entity.dart';

PatientDeviceListEntity $PatientDeviceListEntityFromJson(
    Map<String, dynamic> json) {
  final PatientDeviceListEntity patientDeviceListEntity = PatientDeviceListEntity();
  final String? code = jsonConvert.convert<String>(json['code']);
  if (code != null) {
    patientDeviceListEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    patientDeviceListEntity.msg = msg;
  }
  final PatientDeviceListData? data = jsonConvert.convert<
      PatientDeviceListData>(json['data']);
  if (data != null) {
    patientDeviceListEntity.data = data;
  }
  return patientDeviceListEntity;
}

Map<String, dynamic> $PatientDeviceListEntityToJson(
    PatientDeviceListEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data?.toJson();
  return data;
}

extension PatientDeviceListEntityExtension on PatientDeviceListEntity {
  PatientDeviceListEntity copyWith({
    String? code,
    String? msg,
    PatientDeviceListData? data,
  }) {
    return PatientDeviceListEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

PatientDeviceListData $PatientDeviceListDataFromJson(
    Map<String, dynamic> json) {
  final PatientDeviceListData patientDeviceListData = PatientDeviceListData();
  final int? pageIndex = jsonConvert.convert<int>(json['pageIndex']);
  if (pageIndex != null) {
    patientDeviceListData.pageIndex = pageIndex;
  }
  final int? pageSize = jsonConvert.convert<int>(json['pageSize']);
  if (pageSize != null) {
    patientDeviceListData.pageSize = pageSize;
  }
  final int? totalPage = jsonConvert.convert<int>(json['totalPage']);
  if (totalPage != null) {
    patientDeviceListData.totalPage = totalPage;
  }
  final int? totalCount = jsonConvert.convert<int>(json['totalCount']);
  if (totalCount != null) {
    patientDeviceListData.totalCount = totalCount;
  }
  final List<PatientDeviceListDataData>? data = (json['data'] as List<dynamic>?)
      ?.map(
          (e) =>
      jsonConvert.convert<PatientDeviceListDataData>(
          e) as PatientDeviceListDataData)
      .toList();
  if (data != null) {
    patientDeviceListData.data = data;
  }
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    patientDeviceListData.total = total;
  }
  final int? current = jsonConvert.convert<int>(json['current']);
  if (current != null) {
    patientDeviceListData.current = current;
  }
  final int? records = jsonConvert.convert<int>(json['records']);
  if (records != null) {
    patientDeviceListData.records = records;
  }
  final int? size = jsonConvert.convert<int>(json['size']);
  if (size != null) {
    patientDeviceListData.size = size;
  }
  final int? pages = jsonConvert.convert<int>(json['pages']);
  if (pages != null) {
    patientDeviceListData.pages = pages;
  }
  return patientDeviceListData;
}

Map<String, dynamic> $PatientDeviceListDataToJson(
    PatientDeviceListData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['pageIndex'] = entity.pageIndex;
  data['pageSize'] = entity.pageSize;
  data['totalPage'] = entity.totalPage;
  data['totalCount'] = entity.totalCount;
  data['data'] = entity.data?.map((v) => v.toJson()).toList();
  data['total'] = entity.total;
  data['current'] = entity.current;
  data['records'] = entity.records;
  data['size'] = entity.size;
  data['pages'] = entity.pages;
  return data;
}

extension PatientDeviceListDataExtension on PatientDeviceListData {
  PatientDeviceListData copyWith({
    int? pageIndex,
    int? pageSize,
    int? totalPage,
    int? totalCount,
    List<PatientDeviceListDataData>? data,
    int? total,
    int? current,
    int? records,
    int? size,
    int? pages,
  }) {
    return PatientDeviceListData()
      ..pageIndex = pageIndex ?? this.pageIndex
      ..pageSize = pageSize ?? this.pageSize
      ..totalPage = totalPage ?? this.totalPage
      ..totalCount = totalCount ?? this.totalCount
      ..data = data ?? this.data
      ..total = total ?? this.total
      ..current = current ?? this.current
      ..records = records ?? this.records
      ..size = size ?? this.size
      ..pages = pages ?? this.pages;
  }
}

PatientDeviceListDataData $PatientDeviceListDataDataFromJson(
    Map<String, dynamic> json) {
  final PatientDeviceListDataData patientDeviceListDataData = PatientDeviceListDataData();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    patientDeviceListDataData.id = id;
  }
  final String? sickPersonId = jsonConvert.convert<String>(
      json['sickPersonId']);
  if (sickPersonId != null) {
    patientDeviceListDataData.sickPersonId = sickPersonId;
  }
  final String? hospitalId = jsonConvert.convert<String>(json['hospitalId']);
  if (hospitalId != null) {
    patientDeviceListDataData.hospitalId = hospitalId;
  }
  final String? deviceId = jsonConvert.convert<String>(json['deviceId']);
  if (deviceId != null) {
    patientDeviceListDataData.deviceId = deviceId;
  }
  final String? deviceName = jsonConvert.convert<String>(json['deviceName']);
  if (deviceName != null) {
    patientDeviceListDataData.deviceName = deviceName;
  }
  final String? bmDeviceBluetoothNumber = jsonConvert.convert<String>(
      json['bmDeviceBluetoothNumber']);
  if (bmDeviceBluetoothNumber != null) {
    patientDeviceListDataData.bmDeviceBluetoothNumber = bmDeviceBluetoothNumber;
  }
  final String? deviceBluetoothNumber = jsonConvert.convert<String>(
      json['deviceBluetoothNumber']);
  if (deviceBluetoothNumber != null) {
    patientDeviceListDataData.deviceBluetoothNumber = deviceBluetoothNumber;
  }
  final String? deviceNumber = jsonConvert.convert<String>(
      json['deviceNumber']);
  if (deviceNumber != null) {
    patientDeviceListDataData.deviceNumber = deviceNumber;
  }
  final String? labels = jsonConvert.convert<String>(json['labels']);
  if (labels != null) {
    patientDeviceListDataData.labels = labels;
  }
  final List<
      AcquisitionAcquisitionLabelList>? labelNameList = (json['labelNameList'] as List<
      dynamic>?)?.map(
          (e) =>
      jsonConvert.convert<AcquisitionAcquisitionLabelList>(
          e) as AcquisitionAcquisitionLabelList).toList();
  if (labelNameList != null) {
    patientDeviceListDataData.labelNameList = labelNameList;
  }
  final String? distributionName = jsonConvert.convert<String>(
      json['distributionName']);
  if (distributionName != null) {
    patientDeviceListDataData.distributionName = distributionName;
  }
  final String? distributionTime = jsonConvert.convert<String>(
      json['distributionTime']);
  if (distributionTime != null) {
    patientDeviceListDataData.distributionTime = distributionTime;
  }
  final String? recycleTime = jsonConvert.convert<String>(json['recycleTime']);
  if (recycleTime != null) {
    patientDeviceListDataData.recycleTime = recycleTime;
  }
  final String? recycleUserId = jsonConvert.convert<String>(
      json['recycleUserId']);
  if (recycleUserId != null) {
    patientDeviceListDataData.recycleUserId = recycleUserId;
  }
  final String? recycleUserName = jsonConvert.convert<String>(
      json['recycleUserName']);
  if (recycleUserName != null) {
    patientDeviceListDataData.recycleUserName = recycleUserName;
  }
  final String? recycleRemark = jsonConvert.convert<String>(
      json['recycleRemark']);
  if (recycleRemark != null) {
    patientDeviceListDataData.recycleRemark = recycleRemark;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    patientDeviceListDataData.status = status;
  }
  final String? createTime = jsonConvert.convert<String>(json['createTime']);
  if (createTime != null) {
    patientDeviceListDataData.createTime = createTime;
  }
  final String? updateTime = jsonConvert.convert<String>(json['updateTime']);
  if (updateTime != null) {
    patientDeviceListDataData.updateTime = updateTime;
  }
  final List<String>? labelList = (json['labelList'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (labelList != null) {
    patientDeviceListDataData.labelList = labelList;
  }
  return patientDeviceListDataData;
}

Map<String, dynamic> $PatientDeviceListDataDataToJson(
    PatientDeviceListDataData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['sickPersonId'] = entity.sickPersonId;
  data['hospitalId'] = entity.hospitalId;
  data['deviceId'] = entity.deviceId;
  data['deviceName'] = entity.deviceName;
  data['bmDeviceBluetoothNumber'] = entity.bmDeviceBluetoothNumber;
  data['deviceBluetoothNumber'] = entity.deviceBluetoothNumber;
  data['deviceNumber'] = entity.deviceNumber;
  data['labels'] = entity.labels;
  data['labelNameList'] = entity.labelNameList?.map((v) => v.toJson()).toList();
  data['distributionName'] = entity.distributionName;
  data['distributionTime'] = entity.distributionTime;
  data['recycleTime'] = entity.recycleTime;
  data['recycleUserId'] = entity.recycleUserId;
  data['recycleUserName'] = entity.recycleUserName;
  data['recycleRemark'] = entity.recycleRemark;
  data['status'] = entity.status;
  data['createTime'] = entity.createTime;
  data['updateTime'] = entity.updateTime;
  data['labelList'] = entity.labelList;
  return data;
}

extension PatientDeviceListDataDataExtension on PatientDeviceListDataData {
  PatientDeviceListDataData copyWith({
    String? id,
    String? sickPersonId,
    String? hospitalId,
    String? deviceId,
    String? deviceName,
    String? bmDeviceBluetoothNumber,
    String? deviceNumber,
    String? deviceBluetoothNumber,
    String? labels,
    List<AcquisitionAcquisitionLabelList>? labelNameList,
    String? distributionName,
    String? distributionTime,
    String? recycleTime,
    String? recycleUserId,
    String? recycleUserName,
    String? recycleRemark,
    int? status,
    String? createTime,
    String? updateTime,
    List<String>? labelList,
  }) {
    return PatientDeviceListDataData()
      ..id = id ?? this.id
      ..sickPersonId = sickPersonId ?? this.sickPersonId
      ..hospitalId = hospitalId ?? this.hospitalId
      ..deviceId = deviceId ?? this.deviceId
      ..deviceName = deviceName ?? this.deviceName
      ..bmDeviceBluetoothNumber = bmDeviceBluetoothNumber ??
          this.bmDeviceBluetoothNumber
      ..deviceBluetoothNumber = deviceBluetoothNumber ??
          this.deviceBluetoothNumber
      ..labels = labels ?? this.labels
      ..deviceNumber = deviceNumber ?? this.deviceNumber
      ..labelNameList = labelNameList ?? this.labelNameList
      ..distributionName = distributionName ?? this.distributionName
      ..distributionTime = distributionTime ?? this.distributionTime
      ..recycleTime = recycleTime ?? this.recycleTime
      ..recycleUserId = recycleUserId ?? this.recycleUserId
      ..recycleUserName = recycleUserName ?? this.recycleUserName
      ..recycleRemark = recycleRemark ?? this.recycleRemark
      ..status = status ?? this.status
      ..createTime = createTime ?? this.createTime
      ..updateTime = updateTime ?? this.updateTime
      ..labelList = labelList ?? this.labelList;
  }
}

PatientDeviceListDataDataLabelNameList $PatientDeviceListDataDataLabelNameListFromJson(
    Map<String, dynamic> json) {
  final PatientDeviceListDataDataLabelNameList patientDeviceListDataDataLabelNameList = PatientDeviceListDataDataLabelNameList();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    patientDeviceListDataDataLabelNameList.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    patientDeviceListDataDataLabelNameList.name = name;
  }
  final int? type = jsonConvert.convert<int>(json['type']);
  if (type != null) {
    patientDeviceListDataDataLabelNameList.type = type;
  }
  final String? colour = jsonConvert.convert<String>(json['colour']);
  if (colour != null) {
    patientDeviceListDataDataLabelNameList.colour = colour;
  }
  return patientDeviceListDataDataLabelNameList;
}

Map<String, dynamic> $PatientDeviceListDataDataLabelNameListToJson(
    PatientDeviceListDataDataLabelNameList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['type'] = entity.type;
  data['colour'] = entity.colour;
  return data;
}

extension PatientDeviceListDataDataLabelNameListExtension on PatientDeviceListDataDataLabelNameList {
  PatientDeviceListDataDataLabelNameList copyWith({
    String? id,
    String? name,
    int? type,
    String? colour,
  }) {
    return PatientDeviceListDataDataLabelNameList()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..type = type ?? this.type
      ..colour = colour ?? this.colour;
  }
}